package com.example.demo3;

/**
 * @author 张成
 * @version 1.0
 * @date 2022/3/11 10:41
 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "excelServlet", value = "/excelServlet")
public class ExcelServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
            throws ServletException, IOException {

        response.setHeader("Content-Encoding", "gb2312");
        response.setContentType("application/vnd.ms-excel;charset=gb2312");
        PrintWriter out = response.getWriter();

        out.println("学号\t姓名\t性别\t年龄\t所在系");
        out.println("95001\t李勇\t男\t20\t信息");
        out.println("95002\t刘晨\t女\t19\t数学");
        out.println("95003\t王五\t男\t19\t信息");
    }
}
